package com.sqmf.util;

import lombok.Data;
import lombok.NoArgsConstructor;

@Data
@NoArgsConstructor
public class Result {
    private Integer code;
    private String message;
    private Object data;

    private Result(ResultCode code) {
        this.code = code.code;
        this.message = code.message;
    }

    public Result(ResultCode code, Object data) {
        this.code = code.code;
        this.message = code.message;
        this.data = data;
    }

    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    public static Result SUCCESS(Object data) {
        return new Result(ResultCode.SUCCESS, data);
    }

    public static Result SUCCESS() {
        return new Result(ResultCode.SUCCESS);
    }

    public static Result ERROR(Integer code, String message) {
        return new Result(code, message);
    }

    public static Result FAIL() {
        return new Result(ResultCode.FAIL);
    }

    public static Result API_PARAM_MISS_ERROR() {
        return new Result(ResultCode.API_PARAM_MISS_ERROR);
    }

    public static Result API_SERVER_ERROR() {
        return new Result(ResultCode.API_SERVER_ERROR);
    }

    public static Result API_DATA_ERROR() {
        return new Result(ResultCode.API_DATA_ERROR);
    }

    public static Result API_QUERY_ERROR() {
        return new Result(ResultCode.API_QUERY_ERROR);
    }

}
